﻿package {
	import flash.display.*;
	import flash.external.*;
	import flash.net.*;
	import flash.text.*;
	import flash.events.*;
	public class Sender extends LC {
		public var name_send:String;
		public var lc_send:LocalConnection;
		
		public function Sender():void {
			//发送者，数据固定发送到一个名字
			name_send = "_" + lc + "_" + LISTENER;
			//收听者，用一个随机名字
			name_conn = "_" + lc + "_" + SENDER + "_" + Math.random().toString().substr(2, 8);
			try {
				lc_conn.connect(name_conn);
			} catch (e:ArgumentError) {
				eicall(onstate, e.message);
			}
			lc_send = new LocalConnection();
			lc_send.addEventListener(StatusEvent.STATUS, onStatus);
			lc_send.send(name_send, "reply", name_conn);
			eicall(onloaded, name_conn);
		}
		
		override public function sendData(... rest):void {
			lc_send.send(name_send, "getData", name_conn, rest[0]);
		}
		
		override public function getData(... rest):void {
			eicall(ondata, rest[0]);
		}
		
	}
}